<?php

function to_drawing_array($drawing_object) { 
	//print '<pre>';
    //print_r($drawing_object);
    $ownerEntity    = get_entity($drawing_object->user_id);
    $metaUserIcon   = $ownerEntity->getMetaData('metaUserIcon');
    $iconUrl        = $ownerEntity->getIcon();
    if($metaUserIcon!=null) {
           $iconUrl = $metaUserIcon;
    }
    
    $comment_no      = count_drawing_comment($drawing_object->id);
    $tags           = get_drawing_tags($drawing_object->id);
    
    return array(
        'guid'          => $drawing_object->id,
        'title'         => $drawing_object->title,
        'description'   => $drawing_object->description,
        'owner_guid'    => $drawing_object->user_id,
        'owner_name'    => $ownerEntity->name,
        'owner_icon'    => $iconUrl,
        'location'      => $drawing_object->location_description,
        'comment_no'    => $comment_no,
        'like_no'       => $drawing_object->likes,
        'time'          => $drawing_object->timestamp,
        'width'         => $drawing_object->width,
        'height'        => $drawing_object->height,
        'portrait'      => $drawing_object->orientation,
        'tags'          => $tags,
        'large_url'     => $drawing_object->url,
        'small_url'     => $drawing_object->thumbnail_url,
        'medium_url'    => $drawing_object->thumbnail_url,
        'avg_rating'    => 0,
        'favorite'      => check_whiteboard_favorite(get_loggedin_userid(), $drawing_object->id)
    );
}


function to_drawing_comment_array($comment_object) {

    $userEntity 	= get_user($comment_object->user_id);
    $metaUserIcon   = $userEntity->getMetaData('metaUserIcon');
    $iconUrl 		= $userEntity->getIcon();
    
    if($metaUserIcon!=null) {
            $iconUrl = $metaUserIcon;
    }
    
    return array(
        'owner_guid'    => $comment_object->user_id,
        'owner_name'    => $userEntity->name,
        'owner_icon'    => $iconUrl,
        'value'         => $comment_object->comment,
        'date'          => $comment_object->timestamp
    );
}

function to_whiteboard_xmpp_account_array($xmpp_account_object) {
    return array(
        'guid'      => $xmpp_account_object->id,
        'login'     => $xmpp_account_object->login,
        'domain'    => $xmpp_account_object->domain
    );
}

?>